package com.kordar.api.util;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;

public class ResponseUtil {
    /**
     * 调用成功
     */
    private static final String SUCCESS = "调用成功！";

    public static Response<Object> success(Object obj) {
        Response<Object> res = new Response<>();
        res.setCode(0);
        res.setData(obj);
        res.setMsg(SUCCESS);
        return res;
    }

    public static Response<Object> success() {
        return success(new JSONObject());
    }

    public static Response<Object> error(Integer code, String msg) {
        Response<Object> res = new Response<>();
        res.setCode(code);
        res.setMsg(msg);
        res.setData(new JSONObject());
        return res;
    }

}
